package homeworkSubmission

import org.springframework.cloud.contract.spec.Contract

[Contract.make {
    request {
        method("GET")
        url(value(producer("/api/v3/homeworkSubmission/1/logs")
                , consumer(regex("/api/v3/homeworkSubmission/\\d+/logs"))))
    }
    response {
        status(200)
        body("""
            {
                "status":2,
                "logs":"logs"
            }
            """)
        bodyMatchers {
            jsonPath('$.status', byRegex(number()))
            jsonPath('$.logs', byRegex("[\\s\\S]+"))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
},
 Contract.make {
     request {
         method("GET")
         url("/api/v3/homeworkSubmission/users/1/assignments/1/quizzess/1/logs")
     }
     response {
         status(200)
         body("""
            {
                "id":1,
                "assignmentId":1,
                "quizId":1,
                "userId":1,
                "userAnswer":"userAnswer",
                "status":2,
                "result":"result",
                "answerBranch":"answerBranch",
                "buildNumber":1,
                "commitId":"1"
            }
            """)
         bodyMatchers {
             jsonPath('$.id', byRegex(number()))
             jsonPath('$.assignmentId', byRegex(number()))
             jsonPath('$.quizId', byRegex(number()))
             jsonPath('$.userId', byRegex(number()))
             jsonPath('$.userAnswer', byRegex("[\\s\\S]+"))
             jsonPath('$.status', byRegex(number()))
             jsonPath('$.result', byRegex("[\\s\\S]+"))
             jsonPath('$.answerBranch', byRegex("[\\s\\S]+"))
             jsonPath('$.buildNumber', byRegex(number()))
             jsonPath('$.commitId', byRegex("[\\s\\S]+"))
         }
         headers {
             contentType(applicationJsonUtf8())
         }
     }
 }
]
